package cn.net.xyan.pay.core.entity

import java.math.BigDecimal
import java.util.*
import javax.persistence.*

/**
 * Created by zarra on 2017/3/22.
 */


@Entity
@Table(name = "orders")
data class Order(
        @Id var orderID:String? = null,
        var fee :BigDecimal = BigDecimal.ZERO){

    var status:Int = -1

    @ManyToOne @JoinColumn(name = "medicalCard")
    var medicalCard :MedicalCard? = null

    var totalFee:BigDecimal = fee

    @Temporal(TemporalType.TIMESTAMP)
    var createDate: Date = Date()

    @Temporal(TemporalType.TIMESTAMP)
    var lastModifyDate:Date = Date()

    var title:String = "NoTitle"

    var describe:String = "NoDescribe"

    @ManyToOne @JoinColumn(name = "payVendor")
    var payVendor:PayVendor? = null

    var payVendorNo:String? = null

    var hisReceiptCode:String? = null

    @OneToMany(mappedBy = "order")
    var payRecords:List<PayRecord> = LinkedList()

    @ManyToOne @JoinColumn(name = "hospital")
    var hospital:Hospital?=null
}


data class PayVendorOrder(val vendorOrderID:String){
    var createDate:Date = Date()
}

@Entity
@Table(name = "payRecords")
data class PayRecord(
        @Id var payRecordID:String? = null,

        @ManyToOne @JoinColumn(name = "orderID")
        var order: Order? = null){

    var payFee:BigDecimal = BigDecimal.ZERO

    @Temporal(TemporalType.TIMESTAMP)
    var payTime:Date = Date()

    @ManyToOne @JoinColumn(name = "payVendor")
    var payVendor:PayVendor? = null

    var payVendorRecordNo:String? = null

    @ManyToOne @JoinColumn(name = "hospital")
    var hospital:Hospital?= null
}